<template>
	<div>
		<Card class="content-card">
			<Tabs :animated="false">
				<ButtonGroup slot="extra">

					<Button type="primary" size="small" icon="md-refresh" @click="refreshData"></Button>
				</ButtonGroup>
				<TabPane label="保内维修列表" name="repair">
					<div style="margin-bottom:10px;">
						<span>状态</span>
						<Select v-model="params.insideType" style="width:200px;margin-left: 10px;">
							<Option value="0">待审核</Option>
							<Option value="1">已发布</Option>
							<Option value="2">未通过</Option>
							<Option value="3">确认维修师</Option>
							<Option value="4">维修师进行中</Option>
							<Option value="5">维修师完成</Option>
						</Select>
						<Button @click="refreshData" type="primary">查询</Button>
					</div>
					<table-view ref="tableView" :tableCol='tableCol' :params="params" :type="modalType" :requestUrl='requestUrl'></table-view>
				</TabPane>
			</Tabs>
		</Card>
		<!--查看详情-->
		<detail ref="detail" :type='modalType' @table='operationDone'></detail>
	</div>
</template>

<script>
	import tableView from '../../components/table'
	 import detail from './detail'
	import {
		formatDate
	} from '../utils/time.js'
	export default {
		components: {
			tableView,
			detail
		},
		data() {
			return {
				requestUrl: '/maintain/inside/query/list',
				statusList: {
					0: '待审核',
					1: '已发布',
					2: '未通过',
					3:'确认维修师',
					4:'维修师进行中',
					5:'维修师完成'
				},
				tableCol: [{
						title: '序号',
						type: 'index',
						width: 70
					},{
						title: '主机厂',
						key: 'factoryName',
						minWidth: 120
					},
					{
						title: '类型',
						key: 'typeName',
						minWidth: 100
					}, {
						title: '品牌',
						key: 'brandName',
						minWidth: 100
					}, {
						title: '出厂编号',
						key: 'factoryNumber',
						minWidth: 150
					}, {
						title: '机时',
						key: 'machine',
						minWidth: 100
					}, {
						title: '故障描述',
						key: 'faultDescription',
						minWidth: 150
					}, {
						title: '所需人数',
						key: 'requiredNumber',
						minWidth: 150
					} ,{
						title: '联系方式',
						key: 'userTel',
						minWidth: 150
					}, {
						title: '地址',
						key: 'address',
						minWidth: 150
					}, {
						title: '拒绝原因',
						key: 'refuseReason',
						minWidth: 150
					}, {
						title: '状态',
						minWidth: 100,
						align: 'center',
						render: (h, params) => {
							return h('div', this.statusList[params.row.insideType])
						}
					}, {
						title: '操作',
						key: 'action',
						minWidth: 100,
						render: (h, params) => {
							return h('div', [
								h('Button', {
									props: {
										type: 'error',
										size: 'small'
									},
									on: {
										click: () => {
											this.$Modal.confirm({
												title: '删除？',
												content: '确定要删除吗？删除不可恢复',
												onOk: () => {
													this.$http.post('/maintain/inside/delete', {
														id: params.row.insideId
													}).then(res => {
														if (res.status == 200) {
															this.$refs['tableView'].getData()
															this.$Notice.warning({
																title: '删除成功'

															});
														}
													})
												}
											})
										}
									}
								}, '删除'),
								h('Button', {
									props: {
										type: 'primary',
										size: 'small'
									},
									on: {
										click: () => {
											this.$refs['detail'].show(params)
										}
									}
								}, '查看详情')
							])
						}
					}

				],
				params: {
					pageNo: 1,
					pageSize: 10,
					factoryId: sessionStorage.getItem("factoryId"),
					insideType: ''
				},
				modalType: ''
			}
		},
		mounted() {

		},
		methods: {
			addUser() {
				this.modalType = 'add'
				this.$refs['userOpe'].show()
			},
			refreshData() {
				this.$refs['tableView'].getData()
			},
			operationDone() {
				this.$refs['tableView'].getData()
			},
			queryCarTypeList() {
				this.$http.post('/cartype/list', {
					pageNo: '1',
					pageSize: '100000'
				}).then(res => {
					if (res.status == 200) {
						if (res.data.code == 200) {
							this.catTypeList = res.data.data.rows;
						}

					}
				});
			},
			queryCarBrandList() {
				this.$http.post('/brand/list').then(res => {
					if (res.status == 200) {
						if (res.data.code == 200) {
							this.catBrandList = res.data.data;
						}

					}
				});
			}
		}
	}
</script>
<style scoped>
.content-card{
	width: 100%;
}
</style>
